package com.i_art_engineer.meigong.photo.filter.effect;

import android.content.Context;
import android.graphics.Bitmap;
import android.opengl.GLES20;

public class TwoFilter extends EffectFilter {
    public float contrast=1.0f;
    public Bitmap bmp2;
    public static final String SHADER = "precision lowp float;\n" +
            " precision lowp float;\n" +
            " varying highp vec2 textureCoordinate;\n" +
            " \n" +
            " uniform sampler2D inputImageTexture;\n" +
            " uniform sampler2D inputImageTexture2;\n" +
            " uniform lowp float contrast;\n" +
            "\n" +
            " void main()\n" +
            " {\n" +
            "     \n" +
            "     vec3 texel = texture2D(inputImageTexture, textureCoordinate).rgb;\n" +
            "     \n" +
           "      vec3 texe2 = texture2D(inputImageTexture2, textureCoordinate).rgb;\n "+
            "\n"+
            "     gl_FragColor = vec4(texe2*(1.0-contrast)+texel*contrast, 1.0);\n" +
            " }";
    private int mContrastLocation;

    public TwoFilter(Context context,Bitmap bmp) {
        super(SHADER, 1);
        bitmaps[0]=bmp;//原图ImageUtils.readBitMap(context, R.drawable.filter_lomo_map);
    }
    @Override
    public void onInit() {
        super.onInit();
        mContrastLocation = GLES20.glGetUniformLocation(getProgram(), "contrast");
//        setContrast(1.0f);
    }

    @Override
    public void onInitialized() {
        super.onInitialized();
        setContrast(contrast);
    }
    public void setBmp(Bitmap bmp)
    {
        bitmaps[0]=bmp;
    }
   public void setmContrastLocation(float contrast)
   {
       this.contrast=contrast;
   }
    public void setContrast(final float contrast) {
        this.contrast = contrast;
        setFloat(mContrastLocation, contrast);
    }
}
